{% load staticfiles %}
<!DOCTYPE HTML>
<html lang="zh-CN">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  	<meta charset="utf-8">
    <meta name="description" content="">
    <title>{% block title %}{% endblock %}</title>

    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="{% static 'js/jquery.min.js' %}"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="{% static 'js/bootstrap.min.js' %}"></script>
    <!-- Bootstrap 是移动设备优先的。为了确保适当的绘制和触屏缩放 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <script src="{% static 'js/String.js' %}"></script>

    <link rel="icon" href="{% static 'pictures/favor.ico' %}">

    <!-- 自定义样式表 -->
    <link rel="stylesheet" type="text/css" href="{% static 'css/offcanvas.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"/>
  </head>
  <body>
<script>
function clearCart(elem){
  $.ajax({
    type:'GET',
    url:'/cart/clear/',
    success:function(data){
      data = JSON.parse(data);
      console.log(data['size']);
      $('#cart_sz').text(data['size']);
    },
  })
}
</script>
    <!-- Static navbar -->
    <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="/">饱了么网上订餐系统</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="/">查看餐厅</a></li>
{% if not session.isLogin %}
<li><a href='/customer/signup/'>新用户注册</a></li>
<li><a href='/customer/login/'>登录</a></li>
{% else %}
<li class="dropdown">
  <a href='#' class="dropdown-toggle" data-toggle="dropdown">购物车(<span id='cart_sz'>{{ cart_size|default:0 }}</span>)<span class="caret"></span></a>
  <ul class="dropdown-menu" role="menu">
    <li><a href="/cart/view">订单详情</a></li>
    <li><a href="javascript:void(0);" onclick="clearCart(this)">清空购物车</a></li>
  </ul>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ session.nickname }}<span class="caret"></span></a>
  <ul class="dropdown-menu" role="menu">
    <li><a href="/customer/profile">个人信息</a></li>
    <li class="divider"></li>
    <li><a href='/customer/logout'>退出登录</a></li>
  </ul>
</li>
{% endif %}
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav><!-- 导航栏结束 -->
    <div class="container">
  	{% block body %}{% endblock %}
    </div>
  </body>
</html>
